/**
 * Created by zycool on 2016/9/1.
 * 管道基础数据 - 系统设置
 */


;(function ($, window, document, undefined) {

    /*** 查询条件初始化 start ***/
    // 管道名称
    var $pipeline_name = $('#JQ_pipeline').select3();
    // 管段名称
    var $Pipe_name = $('#JQ_segment').select3();
    // 起点位置
    var $begin = $('#JQ_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId': $pipeline_name, 'pipeSegmentId': $Pipe_name}
    });
    // 终点位置
    var $end = $('#JQ_end').select3({
        title: '终点位置',
        server: true,
        param: {'pipeLineId': $pipeline_name, 'pipeSegmentId': $Pipe_name, 'beginSignId': $begin}
    });
    // 触发管道
    $pipeline_name.element.on('select', function (e, v) {
        var id = v || $pipeline_name.val();
        if (id) {
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                var json = DyyBase.getSelect(dataset);
                $Pipe_name.add(json);
            });
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                var begin = DyyBase.getPos(dataset, 'begin');
                var end = DyyBase.getPos(dataset, 'end');
                $begin.asset(begin);
                $end.asset(end);
            });
        } else {
            $Pipe_name.add([]);
            $begin.add([]);
            $end.add([]);
        }
    });
    // 触发管段
    $Pipe_name.element.on('select', function (e, v) {
        var id = v || $segment.val();
        if (id) {
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                var begin = DyyBase.getPos(dataset, 'begin');
                var end = DyyBase.getPos(dataset, 'end');
                $begin.asset(begin);
                $end.asset(end);
            });
        } else {
            $begin.add([]);
            $end.add([]);
        }
    });
    /***table ***/
    var $table01=$('#JQ_datatable_01');
    var $table02=$('#JQ_datatable_02');
    var $table03=$('#JQ_datatable_03');
    var $table04=$('#JQ_datatable_04');
    var $table05=$('#JQ_datatable_05');
    var $table06=$('#JQ_datatable_06');

    /*** 筛选对象 start ***/
    var filter = {
        // 高压交流输电系统查询
        getInterferenceFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '0';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '0';
            }();
            return filter;
        },
        //高压交流输电系统导出
        getExport: function () {
            return filter.getInterferenceFilter();
        },
        //交流电气化铁路系统
        getElectrifiedFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //交流电气化铁路系统导出
        getElectrifiedExport: function () {
            return filter.getElectrifiedFilter();
        },
        //高压直流输电系统
        getHvdcFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //高压直流输电系统导出
        getHvdcExport: function () {
            return filter.getHvdcFilter();
        },
        //其它阴极保护系统直流干扰
        getCathodicFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //其它阴极保护系统直流干扰导出
        getCathodicExport: function () {
            return filter.getCathodicFilter();
        },
        //其它直流用电设施直流干扰
        getFacilitiesFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //其它直流用电设施直流干扰导出
        getFacilitiesExport: function () {
            return filter.getFacilitiesFilter();
        },
        //直流牵引系统干扰
        getTowFilter: function (data) {
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            // 查询参数
            filter.pipeId = function () {
                var v = $pipeline_name.val();
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeName=function(){
                var v = $pipeline_name.val('text');
                if (v) {
                    return v;
                }
                return '';
            }();
            filter.pipeLineName = function(){
                var v=$pipeline_name.val('text');
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function () {
                var v = $begin.val('mile');
                if (v) {
                    return v;
                }
                return '0';
            }();
            filter.endMileage = function () {
                var v =$end.val('mile');
                if (v) {
                    return v;
                }
                return '0';
            }();
            return filter;
        },
        //直流牵引系统干扰导出
        getTowExport: function () {
            return filter.getTowFilter();
        }
    };

    /*** 筛选对象 end ***/

    /*** 高压交流输电系统start ***/
    var DTROOM;
    function  loadOne(){
        if($('#JQ_ac0_load').text() == '0'){
            //遍历表格
            DTROOM = $table01.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getInterferenceFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Interference_search(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row){
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.beginMileage+ '">'+row.beginMileage+'</span>';
                            }else{
                                return '<span title="' + row.crossMileage+ '">'+row.crossMileage+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row) {
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.pbeginNgm + '">'+row.pbeginNgm+'</span>';
                            }else{
                                return '<span title="' + row.crossNgm + '">'+row.crossNgm+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'testingCompany', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'testingDate', render: function (data) {
                        return '<span title="' + Dyy.getDate(data) + '">' + Dyy.getDate(data) + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac0_load').text('1');
        }
    }
    // 高压交流输电系统详情模板
    var highHvoltage = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'name', title: '交流干扰源名称 : '},
        {name: 'relativePositionRelation', title: '相对位置关系 : '},
        {name: 'minDistance', title: '最小平行间距(m) : '},
        {name: 'parallelMileage', title: '平行长度(m) : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'conductorType', title: '导线类型 : '},
        {name: 'avgHeightOfTheGround', title: '平均对地高度(m) : '},
        {name: 'ratedVolts', title: '额定电压(kV) : '},
        {name: 'loadcurrent', title: '负载电流(A) : '},
        {name: 'threePhaseUnbalancedLoad', title: '三相载荷不平衡度 : '},
        {name: 'shortCircuitFaultCurrent', title: '单相短路故障电流(A) : '},
        {name: 'faultDuration', title: '故障持续时间(h) : '},
        {name: 'groundMinDistance', title: '接地体与管道最小距离(m) : '},
        {name: 'powerPlant', title: '区域内发电厂设置情况记录 : '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: '检测日期 : '},
        {name: 'recorder', title: '记录人 : '},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'beginMileage', title: '平行段起点位置-绝对距离(m) : '},
        {name: 'pbeginNgm', title: '平行段起点位置-最近测试桩 : '},
        {name: 'beginNagmMileage', title: '平行段起点-相对最近测试桩距离(m) : '},
        {name: 'endMileage', title: '平行段终点位置-绝对距离(m) : '},
        {name: 'pendNgm', title: '平行段终点位置-最近测试桩 : '},
        {name: 'endNagmMileage', title: '平行段终点-相对最近测试桩距离(m) : '},
        {name: 'crossMileage', title: ' 交叉点位置信息-绝对距离(m) : '},
        {name: 'crossNgm', title: ' 交叉点位置信息-最近测试桩 : '},
        {name: 'crossNagmMileage', title: ' 交叉点位置信息-相对最近测试桩距离(m) : '},
        {name: 'remarks', title: '备注 : '}
    ];
    // 展开详情
    $table01.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTROOM, $table01, highHvoltage);
    });
    //查询
    $('#JQ_search').click(function () {
       if(DTROOM) {
           DTROOM.draw();
       }
    });
     //导出
    $('#JQ_export_01').click(function () {
        var param = filter.getExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'高压交流输电系统信息表',
            param: param,
            server: DyyBase.root_path +　'/corrctrl/influence/exportTHVACTS.json'
        });

    });
    /*** ***********************************************高压交流输电系统 end ***/

    /*** 交流电气化铁路系统start***/
    var DTELE;
    //  表格遍历
     function loadElectrified(){
        if($('#JQ_ac1_load').text() == '0'){
            DTELE  = $table02.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getElectrifiedFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Electrified(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row){
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.beginMileage+ '">'+row.beginMileage+'</span>';
                            }else{
                                return '<span title="' + row.crossMileage+ '">'+row.crossMileage+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row) {
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.pbeginNgm + '">'+row.pbeginNgm+'</span>';
                            }else{
                                return '<span title="' + row.crossNgm + '">'+row.crossNgm+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'testingCompany', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'testingDate', render: function (data) {
                        return '<span title="' + Dyy.getDate(data) + '">' + Dyy.getDate(data) + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac1_load').text('1');
        }
    }
    // 交流电气化铁路系统详情模板
    var electrifiedDetails = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'name', title: '交流干扰源名称 : '},
        {name: 'relativePositionRelation', title: '相对位置关系 : '},
        {name: 'minDistance', title: '最小平行间距 : '},
        {name: 'parallelMileage', title: '平行长度(m) : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'groundMinDistance', title: '接地体与管道最小距离(m) : '},
        {name: 'substationLocationDesc', title: '牵引变电所位置描述 : '},
        {name: 'minDistanceFromPipe', title: '牵引变电所与管道最小距离(m) : '},
        {name: 'minDistanceTower', title: '高压杆塔与管道最小距离(m): '},
        {name: 'powerSupplyMode', title: '供电方式 : '},
        {name: 'shorTtimeCurrent', title: '供电臂供电电流-短时电流(m) : '},
        {name: 'effectiveCurrent', title: '供电臂供电电流-有效电流(m) : '},
        {name: 'runRecord', title: '运行情况记录 : '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: ' 检测日期 : '},
        {name: 'recorder', title: '记录人 :'},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'beginMileage', title: '平行段起点位置-绝对距离(m) : '},
        {name: 'pbeginNgm', title: '平行段起点位置-最近测试桩 : '},
        {name: 'beginNagmMileage', title: '平行段起点-相对最近测试桩距离(m) : '},
        {name: 'endMileage', title: '平行段终点位置-绝对距离(m) : '},
        {name: 'pendNgm', title: '平行段终点位置-最近测试桩 : '},
        {name: 'endNagmMileage', title: '平行段终点-相对最近测试桩距离(m) : '},
        {name: 'crossMileage', title: ' 交叉点位置信息-绝对距离(m) : '},
        {name: 'crossNgm', title: ' 交叉点位置信息-最近测试桩 : '},
        {name: 'crossNagmMileage', title: ' 交叉点位置信息-相对最近测试桩距离(m) : '},
        {name: 'remarks', title: '备注 : '}

    ];
   // 展开详情
    $table02.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTELE, $table02, electrifiedDetails);
    });
    //查询
    $('#JQ_search-2').click(function () {
        if(DTELE) {
            DTELE.draw();
        }
    });
    //导出
    $('#JQ_export_02').click(function () {
        var param = filter.getElectrifiedExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'交流电气化铁路系统信息表',
            param: param,
            server: DyyBase.root_path +　'/corrctrl/influence/exportACERS.json'
        });
    });

    /********************************************88 交流电气化铁路系统end***/


    /*** 高压直流输电系统start***/
    var DTHVD;
    //  表格遍历
    function loadHvdc(){
        if($('#JQ_ac2_load').text() == '0'){
            DTHVD  = $table03.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getElectrifiedFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Hvdc(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row){
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.beginMileage+ '">'+row.beginMileage+'</span>';
                            }else{
                                return '<span title="' + row.crossMileage+ '">'+row.crossMileage+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row) {
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.pbeginNgm + '">'+row.pbeginNgm+'</span>';
                            }else{
                                return '<span title="' + row.crossNgm + '">'+row.crossNgm+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'testingCompany', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'testingDate', render: function (data) {
                        return '<span title="' + Dyy.getDate(data) + '">' + Dyy.getDate(data) + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac2_load').text('1');
        }
    }
    // 交流电气化铁路系统详情模板
    var hvdcDetails = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'name', title: '直流干扰源名称 : '},
        {name: 'relativePositionRelation', title: '相对位置关系 : '},
        {name: 'minDistance', title: '最小平行间距(m) : '},
        {name: 'parallelMileage', title: '平行长度(m) : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'minDistanceOfTowerGround', title: '线路塔架接地体与管道最小距离(m) : '},
        {name: 'voltageLevel', title: '电压等级(kV) : '},
        {name: 'frequency', title: '单极大地回线运行方式-运行频次 : '},
        {name: 'durationTime', title: '单极大地回线运行方式-持续时间(h) : '},
        {name: 'beginMileage', title: '平行段起点位置-绝对距离(m) : '},
        {name: 'pbeginNgm ', title: '平行段起点位置-最近测试桩 : '},
        {name: 'beginNagmMileage', title: '平行段起点-相对最近测试桩距离(m) : '},
        {name: 'endMileage', title: '平行段终点位置-绝对距离(m) : '},
        {name: 'pendNgm', title: '平行段终点位置-最近测试桩 : '},
        {name: 'endNagmMileage', title: '平行段终点-相对最近测试桩距离(m) : '},
        {name: 'crossMileage', title: ' 交叉点位置信息-绝对距离(m) : '},
        {name: 'crossNgm', title: ' 交叉点位置信息-最近测试桩 : '},
        {name: 'crossNagmMileage', title: ' 交叉点位置信息-相对最近测试桩距离(m) : '},
        {name: 'size', title: '换流站接地极-尺寸 : '},
        {name: 'shape', title: '换流站接地极-形状 : '},
        {name: 'pipeLocationRelationDesc', title: '换流站接地极-与管道位置关系描述 : '},
        {name: 'nearestDistanceToPipe', title: '换流站接地极-与管道最小距离(m): '},
        {name: 'ratedAmpsOut', title: '换流站接地极-额定电流(A): '},
        {name: 'unbalancedCurrent', title: '换流站接地极-不平衡电流(A): '},
        {name: 'maxLoadCurrent', title: '换流站接地极-最大过负荷电流(A) : '},
        {name: 'maxTranSientCurrent', title: '换流站接地极-最大暂态电流（A）: '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: ' 检测日期 : '},
        {name: 'recorder', title: '记录人 : '},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'remarks', title: '备注 : '}
    ];
    // 展开详情
    $table03.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTHVD, $table03, hvdcDetails);
    });
    //查询
    $('#JQ_search-3').click(function () {
        if(DTHVD) {
            DTHVD.draw();
        }
    });
    //导出
    $('#JQ_export_03').click(function () {
        var param = filter.getHvdcExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'高压直流输电系统信息表',
            param: param,
            server: DyyBase.root_path +'/corrctrl/influence/exportHVDCTS.json'
        });
    });

    /******************************************88高压直流输电系统end***/


    /*** 其它阴极保护系统直流干扰start***/
    var DTCAT;
    //  表格遍历
    function loadCathodic(){
        if($('#JQ_ac3_load').text() == '0'){
            DTCAT  = $table04.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getCathodicFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Cathodic(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row){
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.beginMileage+ '">'+row.beginMileage+'</span>';
                            }else{
                                return '<span title="' + row.crossMileage+ '">'+row.crossMileage+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row) {
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.pbeginNgm + '">'+row.pbeginNgm+'</span>';
                            }else{
                                return '<span title="' + row.crossNgm + '">'+row.crossNgm+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'materialType', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'groundBedStructure', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'testingDate', render: function (data) {
                        return '<span title="' + Dyy.getDate(data) + '">' + Dyy.getDate(data) + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac3_load').text('1');
        }
    }
    // 其它阴极保护系统直流干扰模板
    var cathodicDetails = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'dcInfluenceSourceName', title: '直流干扰源名称: '},
        {name: 'relativePositionRelation', title: '相对位置关系 : '},
        {name: 'objectOfProtectionSystem', title: '阴保系统保护对象 : '},
        {name: 'inserviceDate', title: '投用日期 : '},
        {name: 'minDistance', title: '最小平行间距(m) : '},
        {name: 'parallelMileage', title: '平行长度(m) : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'materialType', title: '阳极材料类型 : '},
        {name: 'groundBedStructure', title: '地床构造 : '},
        {name: 'nearestDistanceToPipe', title: '辅助阳极地床与管道最小距离(m): '},
        {name: 'beginMileage', title: '平行段起点位置-绝对距离(m) : '},
        {name: 'pbeginNgm', title: '平行段起点位置-最近测试桩 : '},
        {name: 'beginNagmMileage', title: '平行段起点-相对最近测试桩距离(m) : '},
        {name: 'endMileage', title: '平行段终点位置-绝对距离(m) : '},
        {name: 'pendNgm', title: '平行段终点位置-最近测试桩 : '},
        {name: 'endNagmMileage', title: '平行段终点-相对最近测试桩距离(m) : '},
        {name: 'crossMileage', title: ' 交叉点位置信息-绝对距离(m) : '},
        {name: 'crossNgm', title: ' 交叉点位置信息-最近测试桩 : '},
        {name: 'crossNagmMileage', title: ' 交叉点位置信息-相对最近测试桩距离(m) : '},
        {name: 'operatingVoltsOut', title: '阴保电源输出参数-输出电压(V) : '},
        {name: 'operatingAmpsOut', title: '阴保电源输出参数-输出电流(A) : '},
        {name: 'settingPotential', title: '阴保电源输出参数-控制电位(V) : '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: '检测日期 : '},
        {name: 'recorder', title: '记录人 : '},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'remarks', title: '备注 : '}
    ];
    // 展开详情
    $table04.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTCAT, $table04, cathodicDetails);
    });
    //查询
    $('#JQ_search-4').click(function () {
        if(DTCAT) {
            DTCAT.draw();
        }
    });
    //导出
    $('#JQ_export_04').click(function () {
        var param = filter.getCathodicExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'其它阴极保护系统直流干扰信息表',
            param: param,
            server: DyyBase.root_path +　'/corrctrl/influence/exportOCPS.json'
        });
    });

    /************************************************其它阴极保护系统直流干扰end***/



    /*** 其它直流用电设施直流干扰start***/
    var DTFAC;
    //  表格遍历
    function loadFacilities(){
        if($('#JQ_ac4_load').text() == '0'){
            DTFAC  = $table05.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getFacilitiesFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Facilities(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'customNumber', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'groundPipeMinDistance', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'testingDate', render: function (data) {
                        return '<span title="' + Dyy.getDate(data) + '">' + Dyy.getDate(data) + '</span>';
                    }
                    },
                    {
                        data: 'testingCompany', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac4_load').text('1');
        }
    }
    // 交流电气化铁路系统详情模板
    var FacilitiesDetails = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'name', title: '直流干扰源名称 : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'dcPowerUtilities', title: '直流用电设施用途 : '},
        {name: 'type', title: '类型 : '},
        {name: 'inserviceDate', title: '投用日期 : '},
        {name: 'operatingVoltage', title: '工作电压(V) : '},
        {name: 'operatingCurrent', title: '工作电流(A) : '},
        {name: 'leakageCurrent', title: '泄漏电流(A) : '},
        {name: 'groundPipeMinDistance', title: '接地装置与管道最小距离(m) : '},
        {name: 'durationTime', title: '持续时间(min) : '},
        {name: 'frequency', title: '运行频次 : '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: '检测日期 : '},
        {name: 'recorder', title: '记录人 : '},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'remarks', title: '备注 : '}
    ];
    // 展开详情
    $table05.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTFAC, $table05, FacilitiesDetails);
    });
    //查询
    $('#JQ_search-5').click(function () {
        if(DTFAC) {
            DTFAC.draw();
        }
    });
    //导出
    $('#JQ_export_05').click(function () {
        var param = filter.getFacilitiesExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'其它直流用电设施直流干扰信息表',
            param: param,
            server: DyyBase.root_path +　'/corrctrl/influence/exportODEF.json'
        });
    });

    /*** 其它直流用电设施直流干扰end***/



    /*** 直流牵引系统干扰干扰start***/
    var DTTOW;
    //  表格遍历
    function loadTOW(){
        if($('#JQ_ac5_load').text() == '0'){
            DTTOW  = $table06.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getTowFilter(data);
                    DyyBase.ajax(corrctrlApi.url_Tow(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeName', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'name', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row){
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.beginMileage+ '">'+row.beginMileage+'</span>';
                            }else{
                                return '<span title="' + row.crossMileage+ '">'+row.crossMileage+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'relativePositionRelation', render: function (data,type,row) {
                        if(data){
                            var temp = row.relativePositionRelation;
                            if(temp == '平行'){
                                return '<span title="' + row.pbeginNgm + '">'+row.pbeginNgm+'</span>';
                            }else{
                                return '<span title="' + row.crossNgm + '">'+row.crossNgm+'</span>';
                            }
                        }
                    }
                    },
                    {
                        data: 'testingCompany', render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                    },
                    {
                        data: 'id', render: function (data) {
                        return '<i title="展开详情" class="zy-details-icon" data-id="' + data + '"></i>';
                    }
                    }
                ]
            });
            $('#JQ_ac5_load').text('1');
        }
    }
    // 交流电气化铁路系统详情模板
    var towDetails = [
        {name: 'pipeName', title: '管道名称 : '},
        {name: 'customNumber', title: '干扰源编号 : '},
        {name: 'name', title: '直流干扰源名称 : '},
        {name: 'relativePositionRelation', title: '相对位置关系 : '},
        {name: 'minDistance', title: '最小平行间距(m) : '},
        {name: 'parallelMileage', title: '平行长度(m) : '},
        {name: 'locationDescription', title: '位置描述 : '},
        {name: 'inserviceDate', title: '投用日期 : '},
        {name: 'powerSupplyMode', title: '供电方式 : '},
        {name: 'feedMode', title: '馈电方式 : '},
        {name: 'feedElectrodeProperty', title: '馈电极性 : '},
        {name: 'tractionCurrent', title: '牵引电流(A) : '},
        {name: 'minDistanceFromPipe', title: '直流供电所与管道最小距离(m) : '},
        {name: 'substationLocationDesc', title: '直流供电所位置描述 : '},
        {name: 'runningStatusOfTram', title: '电车运行状况 : '},
        {name: 'beginMileage', title: '平行段起点位置-绝对距离(m) : '},
        {name: 'pbeginNgm', title: '平行段起点位置-最近测试桩 : '},
        {name: 'beginNagmMileage', title: '平行段起点-相对最近测试桩距离(m) : '},
        {name: 'endMileage', title: '平行段终点位置-绝对距离(m) : '},
        {name: 'pendNgm', title: '平行段终点位置-最近测试桩 : '},
        {name: 'endNagmMileage', title: '平行段终点-相对最近测试桩距离(m) : '},
        {name: 'crossMileage', title: ' 交叉点位置信息-绝对距离(m) : '},
        {name: 'crossNgm', title: ' 交叉点位置信息-最近测试桩 : '},
        {name: 'crossNagmMileage', title: ' 交叉点位置信息-相对最近测试桩距离(m) : '},
        {name: 'testingCompany', title: '检测单位 : '},
        {name: 'testingDate', title: ' 检测日期 : '},
        {name: 'recorder', title: '记录人 : '},
        {name: 'recordTime', title: '记录时间 : '},
        {name: 'remarks', title: '备注 : '}

    ];
    // 展开详情
    $table06.on('click', 'i.zy-details-icon', function () {
        DyyBase.showDetails($(this), DTTOW, $table06, towDetails);
    });
    //查询
    $('#JQ_search-6').click(function () {
        if(DTTOW) {
            DTTOW.draw();
        }
    });
    //导出
    $('#JQ_export_06').click(function () {
        var param = filter.getTowExport;
        if(param instanceof Function){
            param = param();
        }
        $(this).EXPT({
            type: 'name',
            name: param.pipeName+'直流牵引系统干扰信息表',
            param: param,
            server: DyyBase.root_path +　'/corrctrl/influence/exportDCTS.json'
        });
    });



    var $nav = $('.lsk-tab-0>li');
    var $nav_content = $('div.lsk-tab-main');

    /*** html5的本地储存方式，作用：在不关闭页面的情况下，刷新能实现刷线当前tab页，不会跳转到初始化页面 ***/
    if(window.sessionStorage.TypeSave == 'DPOWER'){
        $nav.eq(0).addClass('active');
        $nav_content.eq(0).show();
        loadOne();
    }else if(window.sessionStorage.TypeSave == 'DLONG'){
        $nav.eq(1).addClass('active');
        $nav_content.eq(1).show();
        loadElectrified();
    }else if(window.sessionStorage.TypeSave == 'DBED'){
        $nav.eq(2).addClass('active');
        $nav_content.eq(2).show();
        loadHvdc();
    }else if(window.sessionStorage.TypeSave == 'DINSU'){
        $nav.eq(3).addClass('active');
        $nav_content.eq(3).show();
        loadCathodic();
    }else if(window.sessionStorage.TypeSave == 'DAVOID'){
        $nav.eq(4).addClass('active');
        $nav_content.eq(4).show();
        loadFacilities();
    }else if(window.sessionStorage.TypeSave == 'DLINE'){
        $nav.eq(5).addClass('active');
        $nav_content.eq(5).show();
        loadTOW();
    }else{
        $nav.eq(0).addClass('active');
        $nav_content.eq(0).show();
        loadOne();
    }
        //展开与收起
    $('#JQ_datatable_01').delegate('.zy-details-icon','click',function(){
        $(this).addClass('active');
    })

    /*** 直流牵引系统干扰end***/
        // 切换
    $nav.click(function () {
        var $this = $(this);
        var index = $this.index();
        $this.siblings('li').removeClass('active');
        $this.addClass('active');
        var $divs = $('.lsk-tab-contents').find('.lsk-tab-main');
        $divs.hide().eq(index).show();
        if(index == 0){
            $('#JQ_filter_form').reset();
            //if(DTROOM){
            //    DTROOM.draw();
            //}
            loadOne();
            window.sessionStorage.TypeSave = 'DPOWER';
        }else if(index == 1){
            $('#JQ_filter_form').reset();
            loadElectrified();
            window.sessionStorage.TypeSave = 'DLONG';
        }else if(index == 2){
            $('#JQ_filter_form').reset();
            loadHvdc();
            window.sessionStorage.TypeSave = 'DBED';
        }else if(index == 3){
            $('#JQ_filter_form').reset();
            loadCathodic();
            window.sessionStorage.TypeSave = 'DINSU';
        }else if(index == 4){
            $('#JQ_filter_form').reset();
            loadFacilities();
            window.sessionStorage.TypeSave = 'DAVOID';
        }else if(index == 5){
            $('#JQ_filter_form').reset();
            loadTOW();
            window.sessionStorage.TypeSave = 'DLINE';
        }
    });


})(jQuery, window, document);